import pandas as pd
import numpy as np

dates = pd.date_range('20200601', periods=6)
df = pd.DataFrame(np.arange(24).reshape(6, 4), index=dates, columns=['a', 'b', 'c', 'd'])
# print(df)

# 选取a列
print(df['a'])
# 选择前3行
print(df[0:3])

# 根据标签进行行选择
print(df.loc['20200601'])
# 根据标签进行列选择
print(df.loc[:, ['a', 'c']])
print(df.drop(['b', 'd'], axis=1))

# 有条件的筛选
print(df[df['a'] > 8])

# 修改值
df.loc[:,'a'] = 222
print(df)